var $ = require("../../utils/Ajax.js");
Page({
  data: {
    PictureUrl: getApp().PictureUrl,
    // 数据
    SecKillAssemble: [],
    Type: null
  },

  onLoad: function (options) {
    var that = this;
    that.setData({
      Type: options.Type
    })
    if (options.Type == 0){
      wx.setNavigationBarTitle({
        title: "拼团"
      })
    }else{
      wx.setNavigationBarTitle({
        title: "秒杀"
      })
    }

    $.Ajax("api/act","POST",{
      t: options.Type
    },function(res){
      if(res.s){
        that.setData({
          SecKillAssemble: res.d.activity
        })
      }
    })
  },

  onShow: function () {

  },

  // 点击选择
  SelectAct: function(e){
    var that = this;
    var Id = e.currentTarget.dataset.id;
    $.Ajax("api/setAct","POST",{
      t: that.data.Type,
      id: Id
    },function(res){
      if(res.s){
        $.Ajax("api/act", "POST", {
          t: that.data.Type
        }, function (res) {
          if (res.s) {
            that.setData({
              SecKillAssemble: res.d.activity
            })
          }
        })
      }
      wx.showToast({
        title: res.m,
        icon: 'none',
        duration: 2000,
        mask: true
      })
    })
  }
})